/**
 * @Author: 九璃怀特 1599130621@qq.com
 * @Date: 2023-12-26 09:31:17
 * @LastEditors: 九璃怀特 1599130621@qq.com
 * @LastEditTime: 2023-12-26 09:31:59
 * @FilePath: \zxi-surface-guide\src\utils\view.ts
 * @Description:
 */
export const throttle = (fun: Function, delay: number) => {
  let init = true,
    timer: any = null;
  return function (...args: any) {
    if (init) {
      init = false;
      fun(args);
    } else {
      if (timer) {
        clearTimeout(timer);
      }
      timer = setTimeout(() => {
        fun(args);
      }, delay);
    }
  };
};
